<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <c:set var="ctx" value="${pageContext.request.contextPath}"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>结清选择期次页面</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div id="pageInTab" class="pageInTab">
        <form id="formSet1">
            <div class="fieldset1 tabel_col clearFix">
                <div class="fieldBox col_50">
                    <div class="label"><b>融资租赁合同号</b></div>
                    <div class="field">
                        <span>${prj.lsCntNo}</span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label"><b>承租人</b></div>
                    <div class="field">
                        <span>${prj.cstNm }</span>
                    </div>
                </div>
            <c:if test="${enabledPaySchM.paySchTypCd == 'ZF'}">
                <div class="fieldBox col_50">
                    <div class="label"><b>资方支付表号</b></div>
                    <div class="field">
                        <span>${enabledPaySchM.paySchNo }</span>
                    </div>
                </div>
                <div class="fieldBox col_100">
                    <div class="label"><b>我司支付表号</b></div>
                    <div class="field">
                        <c:forEach items="${wsPaySchList }" var="wsPaySch">
                            <span>${wsPaySch.paySchNo }</span><br/>
                        </c:forEach>
                    </div>
                </div>
            </c:if>
            <c:if test="${enabledPaySchM.paySchTypCd != 'ZF'}">
                <div class="fieldBox col_50">
                    <div class="label"><b>支付表号</b></div>
                    <div class="field">
                        <span>${enabledPaySchM.paySchNo }</span>
                    </div>
                </div>
            </c:if>
                <div class="fieldBox col_50">
                    <div class="label"><b>开始期次</b></div>
                    <div class="field">
                        <%--<c:if test="${enabledPaySchM.startLsPd != 0}">
                            <select id="startLsPd">
                                <c:forEach begin="${enabledPaySchM.startLsPd}" end="${enabledPaySchM.lsPd}" step="1" var="pd">
                                    <option value="${pd}" <c:if test="${pd == enabledPaySchM.defStartLsPd}"> selected="selected"</c:if>>第${pd}期</option>
                                </c:forEach>
                            </select>
                        </c:if>
                        <c:if test="${enabledPaySchM.startLsPd == 0}">到期</c:if>--%>
                        <input name="startLsPd" id="startLsPd" data-value="" placeholder="请选择" ltype="combobox">
                    </div>
                </div>
            </div>
            <div class="btnsBox">
                <span id="showBtn1" class="sq-button sq-button-round">预览</span>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    // alert error
    var error = '${error}';
    var paySchTypCd = '${enabledPaySchM.paySchTypCd}';
    if (error == '1') {
        $.ligerDialog.SQalert({
            content: '${errorMsg}',
            SQ_type: "error",
            SQ_showButtons: true,
            SQ_onBtnclick: function () {
                Remove_navTab();
                var callback = frameElement.W2W.callback;
                callback();
            }
        });
    }

    var paySchId = '${enabledPaySchM.id }';
    var prjId = '${enabledPaySchM.prjId }';
    var startLsPd = '${enabledPaySchM.startLsPd}';
    var payPd = '${enabledPaySchM.lsPd}';
    $(function () {
        $('#formSet1').ligerForm({
            validate: true
        });

        var data = [];
        if (startLsPd == 0) {
            data[0] = {id: startLsPd, text:'到期'}
        } else {
            for (var i = 0; i <= (payPd - startLsPd); i++) {
                var j = NumberUtils.add(startLsPd, i);
                data[i] = {id: j, text: '第' + j + '期'};
            }
        }

        $("#startLsPd").ligerComboBox({
            data: data,
            value: startLsPd,
            readonly: false
        });


    });

    $("#showBtn1").click(function () {
        var startLsPd = liger.get("startLsPd").getValue();
        if (startLsPd == "") {
            $.ligerDialog.SQalert({content: "请选择开始期次！", SQ_type: "error"});
            return;
        }

        var callbackRefresh = function () {
            Remove_navTab();
            // 回调
            var callback = frameElement.W2W.callback;
            callback();
        }
        var tabid, text, url = '<%=path%>';
        if (paySchTypCd == 'ZF') {
            tabid = 'TAB_TO_SETTLE_PREVIEW_' + prjId;
            text = '资管结清信息预览';
            url += '/project/financialInst/showZGSettlePage.do?taskDefKey=FLOW_0000_065_001&settleTyp=3&fileAuth=1';
            url += '&prjId=' + prjId;
            url += '&settlePd=' + startLsPd;
        } else {
            tabid = 'TAB_TO_SETTLE_PREVIEW_' + paySchId;
            text = '我司结清信息预览';
            url += '/settlement/bill/preview.do?paySchId=' + paySchId + '&settlePd=' + startLsPd;
        }
        Add_navTab(tabid, text, url, callbackRefresh);
    });
</script>
</body>
</html>
